package com.xsy.carRental.mapper;

import com.github.pagehelper.Page;
import com.xsy.carRental.dto.VehicleAddDTO;
import com.xsy.carRental.dto.VehiclePageQueryDTO;
import com.xsy.carRental.entity.Vehicle;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface VehicleMapper {

    /**
     * 新增车辆
     * @param vehicle
     */
    @Insert("insert into vehicle (license_plate,make,model,year,daily_rate)"+
            "VALUES (#{licensePlate},#{make},#{model},#{year},#{dailyRate})")
    void add(Vehicle vehicle);

    /**
     * 分页查询车辆
     * @param vehiclePageQueryDTO
     * @return
     */
    Page<Vehicle> pageQuery(VehiclePageQueryDTO vehiclePageQueryDTO);

    /**
     * 更新车辆信息
     * @param vehicle
     */
    void update(Vehicle vehicle);

    /**
     * 根据id删除车辆
     * @param vehicleId
     */
    @Delete("delete from vehicle where vehicle_id=#{vehicleId}")
    void delete(int vehicleId);

    /**
     * 根据id查询车辆详细信息
     * @param vehicleId
     * @return
     */
    @Select("select * from vehicle where vehicle_id=#{vehicleId}")
    Vehicle getVehicleById(int vehicleId);
}
